<?php
/**
 * Created by PhpStorm.
 * User: tangmusen
 * Date: 2017/10/30
 * Time: 11:08
 */
namespace app\home\controller;

use think\Controller;
use think\Db;
use think\Request;

class Lottery extends Base
{
    /**
     * 开奖
     */
    public function index(){

        $data = Db::name('cate')->field('id,name')->where('id','<',13)->select();
        foreach ($data as $k=>$v){
            switch ($v['id']){
                case 1:
                    $number = getNumberCache('eight');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr_s = explode(',',$numbers['number']);
                    $number_arr = getEightNum($number_arr_s);

                    $total_number = array_sum($number_arr);
                    $number_arr[] = $total_number;
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number)."波";//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 2:
                    $number = getNumberCache('canada');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr_s = explode(',',$numbers['number']);
                    $number_arr = getCanadaNum($number_arr_s);
                    $total_number = array_sum($number_arr);
                    $number_arr[] = $total_number;
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number)."波";//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 3:
                    $number = getNumberCache('car');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);

                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDx($ling); //判断大小
                    $er  = carDs($ling);//判断单双
                    $san = longfu($number_arr[0],$number_arr[9]);//判断龙虎
                    $si  = longfu($number_arr[1],$number_arr[8]);//判断龙虎
                    $wu  = longfu($number_arr[2],$number_arr[7]);//判断龙虎
                    $liu = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $qi  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 4:
                    $number = getNumberCache('airship');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDx($ling); //判断大小
                    $er  = carDs($ling);//判断单双
                    $san = longfu($number_arr[0],$number_arr[9]);//判断龙虎
                    $si  = longfu($number_arr[1],$number_arr[8]);//判断龙虎
                    $wu  = longfu($number_arr[2],$number_arr[7]);//判断龙虎
                    $liu = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $qi  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 5:
                    $number = getNumberCache('ssc');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);

                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);

                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);

                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);
                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 6:
                    $number = getNumberCache('tjssc');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);

                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);

                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);

                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);

                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 7:
                    $number = getNumberCache('gd10');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 8:
                    $number = getNumberCache('cq10');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
                    //计算下次期数 和 开间时间
                    $ssc = setcq10StageTime($stage,$numbers['dateline']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 9:
                    $number = getNumberCache('fast');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
                    $he = array_sum($number_arr); //和
                    $dx = FastDx($he);//判断大小
                    $detail = $he.",".$dx;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 10:
                    $number = getNumberCache('gd11');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = gd11zdx($ling); //判断大小
                    $er  = gd11ds($ling);//判断单双
                    $san = gd11lf($number_arr);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san;
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
                case 11:
                    $number = getNumberCache('hk');
                    $stage= key($number); //获取最新一期的key（即期数）
                    $numbers =$number[$stage]; //获取最新开奖号
                    $number_arr = explode(',',$numbers['number']);
//                    $dx    = hkdx($number_arr[6]); //判断大小
//                    $ds    = hkds($number_arr[6]);//判断单双
//                    $sebo  = hkhll($number_arr[6]);
//                    $hkwei = hkwei($number_arr[6]);
//
//
//                    $detail = $ds.",".$dx.",".$sebo.",".$hkwei;
                    $detail = get_zodiac($number_arr);
                    $dateline = date('H:i',strtotime($numbers['dateline']));
                    break;
            }
            $data[$k]['dateline'] = $dateline;
            $data[$k]['number']   = $number_arr;
            $data[$k]['stage']    = $stage;
            $data[$k]['detail']   = $detail;
        }
        return view('',[
            'data'=>$data
        ]);
    }
    
    /**
     * 历史
     */
    public function history(Request $request){
        $cate    = $request->param('cate');
        $stage   = $request->param('stage');
        $page    = $request->post('page')?$request->post('page'):1;
        $limit = 10;
        $start = ($page-1)*$limit;
        $w = [];
        if($stage) {
            $w['stage'] = $stage;
        }
        switch($cate) {
            case 1:
                $number = Db::name('at_eight')
                ->where($w)
                ->limit($start, $limit)
                ->order('id desc')
                ->select();
                $total = Db::name('at_fast')->count();
                foreach ($number as $k => $v) {
                    $number_arr_s = explode(',', $v['number']);
                    $total_number = array_sum(getEightNum($number_arr_s));
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number);//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $number[$k]['number']   = getEightNum($number_arr_s);
                    $number[$k]['number'][] = $total_number;
                    $number[$k]['detail']   = $detail;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = 'PC蛋蛋';
                break;
            case 2:
                $number = Db::name('at_canada')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_canada')->count();
                foreach ($number as $k=>$v){
                    $number_arr_s = explode(',',$v['number']);
                    $total_number = array_sum(getCanadaNum($number_arr_s));
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number);//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $number[$k]['number']   = getCanadaNum($number_arr_s);
                    $number[$k]['number'][] = $total_number;
                    $number[$k]['detail']   = $detail;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '加拿大28';
                break;
            case 3:
                $number = Db::name('at_car')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_car')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDx($ling); //判断大小
                    $er  = carDs($ling);//判断单双
                    $san = longfu($number_arr[0],$number_arr[9]);//判断龙虎
                    $si  = longfu($number_arr[1],$number_arr[8]);//判断龙虎
                    $wu  = longfu($number_arr[2],$number_arr[7]);//判断龙虎
                    $liu = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $qi  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '北京赛车';
                break;
            case 4:
                $page    = $request->post('page')?$request->post('page'):1;
                $limit = 10;
                $start = ($page-1)*$limit;
                $number = Db::name('at_airship')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_airship')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDx($ling); //判断大小
                    $er  = carDs($ling);//判断单双
                    $san = longfu($number_arr[0],$number_arr[9]);//判断龙虎
                    $si  = longfu($number_arr[1],$number_arr[8]);//判断龙虎
                    $wu  = longfu($number_arr[2],$number_arr[7]);//判断龙虎
                    $liu = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $qi  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '幸运飞艇';
                break;
            case 5:
                $number = Db::name('at_ssc')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_ssc')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);
                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);
                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);
                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '重庆时时彩';
                break;
            case 6:
                $number = Db::name('at_tjssc')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_tjssc')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);
                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);
                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);
                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '天津时时彩';
                break;
            case 7:
                $number = Db::name('at_gd10')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_gd10')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '广州快乐十分';
                break;
            case 8:
                $number = Db::name('at_cq10')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_cq10')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '重庆快乐十分';
                break;
            case 9:
                $number = Db::name('at_fast')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_fast')->count();
                foreach ($number as $k=>$v){
                    $number_arr_s = explode(',',$v['number']);
                    $he = array_sum($number_arr_s); //和
                    $dx = FastDx($he);//判断大小
                    $detail = $he.",".$dx;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr_s;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '江苏快三';
                break;
            case 10:
                $number = Db::name('at_gd11')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_gd11')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = gd11zdx($ling); //判断大小
                    $er  = gd11ds($ling);//判断单双
                    $san = gd11lf($number_arr);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '广东11选5';
            break;
            case 11:
                $number = Db::name('at_hk')
                    ->where($w)
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_hk')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
//                    $dx    = hkdx($number_arr[6]); //判断大小
//                    $ds    = hkds($number_arr[6]);//判断单双
//                    $sebo  = hkhll($number_arr[6]);
//                    $hkwei = hkwei($number_arr[6]);
//                    $detail = $ds.",".$dx.",".$sebo.",".$hkwei;
                    $detail = get_zodiac($number_arr);
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '香港六合彩';
                break;
        }
        $return_data['cate']       = $cate;
        $return_data['trend']      = $number;
        $return_data['now_page']   = $page;
        $return_data['per_page']   = $limit;
        $return_data['total_page'] = ceil($total/$limit);
        return view('',[
            'return_data'=>$return_data
        ]);
    }

    /**
     * 开奖历史api
     */
    public function history_api(Request $request){
        $cate    = $request->param('cate');
        $page    = $request->param('page')?$request->param('page'):1;
        $limit = 10;
        $start = ($page-1)*$limit;
        switch($cate) {
            case 1:
                $number = Db::name('at_eight')
                    ->limit($start, $limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_fast')->count();
                foreach ($number as $k => $v) {
                    $number_arr_s = explode(',', $v['number']);
                    $total_number = array_sum(getEightNum($number_arr_s));
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number);//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $number[$k]['number']   = getEightNum($number_arr_s);
                    $number[$k]['number'][] = $total_number;
                    $number[$k]['detail']   = $detail;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = 'PC蛋蛋';
                break;
            case 2:
                $number = Db::name('at_canada')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_canada')->count();
                foreach ($number as $k=>$v){
                    $number_arr_s = explode(',',$v['number']);
                    $total_number = array_sum(getEightNum($number_arr_s));
                    $dx = eightDx($total_number); //判断大小
                    $ds = eightDs($total_number);//判断单双
                    $bo = eightBo($total_number);//判断波色
                    $detail = $total_number.",".$dx.",".$ds.","."--".",".$bo;
                    $number[$k]['number']   = getEightNum($number_arr_s);
                    $number[$k]['number'][] = $total_number;
                    $number[$k]['detail']   = $detail;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '加拿大28';
                break;
            case 3:
                $number = Db::name('at_car')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_car')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDxWei($number_arr[1]); //判断大小
                    $er  = carDs($number_arr[2]);//判断单双
                    $san = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $si  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $wu  = longfu($number_arr[5],$number_arr[4]);//判断龙虎
                    $liu = longfu($number_arr[6],$number_arr[3]);//判断龙虎
                    $qi  = longfu($number_arr[7],$number_arr[2]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '北京赛车';
                break;
            case 4:
                $page    = $request->post('page')?$request->post('page'):1;
                $limit = 10;
                $start = ($page-1)*$limit;
                $number = Db::name('at_airship')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_airship')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = $number_arr[0]+$number_arr[1];//冠亚军和值
                    $yi  = carDxWei($number_arr[1]); //判断大小
                    $er  = carDs($number_arr[2]);//判断单双
                    $san = longfu($number_arr[3],$number_arr[6]);//判断龙虎
                    $si  = longfu($number_arr[4],$number_arr[5]);//判断龙虎
                    $wu  = longfu($number_arr[5],$number_arr[4]);//判断龙虎
                    $liu = longfu($number_arr[6],$number_arr[3]);//判断龙虎
                    $qi  = longfu($number_arr[7],$number_arr[2]);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si.",".$wu.",".$liu.",". $qi;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '幸运飞艇';
                break;
            case 5:
                $number = Db::name('at_ssc')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_ssc')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);
                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);
                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);
                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '重庆时时彩';
                break;
            case 6:
                $number = Db::name('at_tjssc')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_tjssc')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $he = array_sum($number_arr);
                    $dx = sscDx($he); //判断大小
                    $ds = sscDs($he);//判断单双
                    $longfu = sscLh($number_arr);
                    $first_three = take_three($number_arr,0);
                    $r_first_three = judge_three($first_three);
                    $second_three = take_three($number_arr,1);
                    $r_second_three = judge_three($second_three);
                    $third_three = take_three($number_arr,2);
                    $r_third_three = judge_three($third_three);
                    $niuniu = niuNiu($number_arr);
                    $detail = $he.",".$dx.",".$ds.",".$longfu.",". $r_first_three.",".$r_second_three.",".$r_third_three.",".$niuniu;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '天津时时彩';
                break;
            case 7:
                $number = Db::name('at_gd10')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_gd10')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '广州快乐十分';
                break;
            case 8:
                $number = Db::name('at_cq10')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_cq10')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = Zgd10dx($ling); //判断大小
                    $er  = Zgd10ds($ling);//判断单双
                    $san = Zgd10weidx($ling);//判断龙虎
                    $si  = Zgd10weids($ling);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san.",". $si;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '重庆快乐十分';
                break;
            case 9:
                $number = Db::name('at_fast')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_fast')->count();
                foreach ($number as $k=>$v){
                    $number_arr_s = explode(',',$v['number']);
                    $he = array_sum($number_arr_s); //和
                    $dx = FastDx($he);//判断大小
                    $detail = $he.",".$dx;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr_s;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '江苏快三';
                break;
            case 10:
                $number = Db::name('at_gd11')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_gd11')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
                    $ling = array_sum($number_arr);//冠亚军和值
                    $yi  = gd11zdx($ling); //判断大小
                    $er  = gd11ds($ling);//判断单双
                    $san = gd11lf($number_arr);//判断龙虎
                    $detail = $ling.",".$yi.",".$er.",".$san;
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '广东11选5';
                break;
            case 11:
                $number = Db::name('at_hk')
                    ->limit($start,$limit)
                    ->order('id desc')
                    ->select();
                $total = Db::name('at_hk')->count();
                foreach ($number as $k=>$v){
                    $number_arr = explode(',',$v['number']);
//                    $dx    = hkdx($number_arr[6]); //判断大小
//                    $ds    = hkds($number_arr[6]);//判断单双
//                    $sebo  = hkhll($number_arr[6]);
//                    $hkwei = hkwei($number_arr[6]);
//                    $detail = $ds.",".$dx.",".$sebo.",".$hkwei;
                    $detail = get_zodiac($number_arr);
                    $number[$k]['detail']  = $detail;
                    $number[$k]['number']  = $number_arr;
                    $number[$k]['dateline']  = date('m-d H:i',strtotime($v['dateline']));
                }
                $return_data['cate_name']       = '香港六合彩';
                break;
        }
        $return_data['cate']       = $cate;
        $return_data['trend']      = $number;
        $return_data['now_page']   = $page;
        $return_data['per_page']   = $limit;
        $return_data['total_page'] = ceil($total/$limit);
       json_return(200,'Success',$return_data);
    }

}